#include "StateManager.h"


StateManager* StateManager::getInstance()
{
	if (!_instance)
		_instance = new StateManager();
	return _instance;
		
}

void StateManager::releaseInstance()
{
	if (_instance)
	{
		delete _instance;
		_instance = NULL;
	}
}

void StateManager::addScene(FWGame* GameState)
{
	_listScene.push_back(GameState);	
}


void StateManager::returnPreScene()
{
	if (!_listScene.empty())
		_listScene.pop_back();
}


FWGame* StateManager::getCurrentScene()
{
	return _listScene.back();
}

void StateManager::clearAll()
{
	vector<FWGame *>::iterator it;
	it = _listScene.begin();
	while (!_listScene.empty() && it!= _listScene.end())
	{
		(*it)->shutdown();
		_listScene.pop_back();
		
	}
}


StateManager::StateManager()
{
}

StateManager::~StateManager()
{
}
